//
//  AboutViewController.m
//  TasteEnjoy
//
//  Created by XuRui on 16/5/4.
//  Copyright © 2016年 XuRui. All rights reserved.
//

#import "AboutViewController.h"

@interface AboutViewController ()

@property (nonatomic, retain) BaseButton *buttonOk;
@property (nonatomic, retain) BaseImageView *imgBack;
@property (nonatomic, retain) BaseLabel *labelContent;
@property (nonatomic, retain) BaseImageView *imgHeader;
@end

@implementation AboutViewController

- (void)dealloc
{
    [_labelContent release];
    [_imgBack release];
    [_buttonOk release];
    [_imgHeader release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self creatBackGround];
    [self creatView];
    [self creatBack];
}

#pragma mark - ------------ 创建背景图片 ---------------
- (void)creatBackGround
{
    
    self.imgBack = [[BaseImageView alloc]initWithFrame:self.view.bounds];
    _imgBack.image = [UIImage imageNamed:@"yin2.jpg"];
    _imgBack.userInteractionEnabled = YES;
    [self.view addSubview:_imgBack];
    [_imgBack release];
    
    //模糊
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    //创建个视图把效果加上.
    UIVisualEffectView *view = [[UIVisualEffectView alloc] initWithEffect:effect];
    //设置尺寸.
    view.frame = self.view.bounds;
    //加到已存在的图片上.
    [self.imgBack addSubview:view];
    [view release];
}





#pragma mark - ------------ 创建文字 + app图标 ---------------
- (void)creatView
{

    //文字
    self.labelContent = [[BaseLabel alloc]init];
    [self.imgBack addSubview:_labelContent];
    _labelContent.backgroundColor = [UIColor blackColor];
    _labelContent.alpha = 0.5;
    [_labelContent mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(self.imgBack);
        make.left.mas_equalTo(self.imgBack).offset(40);
        make.right.mas_equalTo(self.imgBack).offset(-40);
        make.height.mas_equalTo(150);
    }];
    
    _labelContent.layer.cornerRadius = 10;
    _labelContent.clipsToBounds = YES;
    _labelContent.numberOfLines = 0;
    _labelContent.text = @"© 2016 arui.com\n版本:1.1(950314)学习\n交流关于ios开发";
    _labelContent.textAlignment = NSTextAlignmentCenter;
    _labelContent.textColor = [UIColor lightGrayColor];
    _labelContent.font = [UIFont systemFontOfSize:15];
    [_labelContent release];
    
    
    //app图标
    self.imgHeader = [[BaseImageView alloc]init];
    [self.imgBack addSubview:_imgHeader];
    _imgHeader.image = [UIImage imageNamed:@"app"];
    _imgHeader.translatesAutoresizingMaskIntoConstraints = NO;
    [_imgHeader mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(_labelContent.mas_top).offset(-20);
        make.width.height.mas_equalTo(80);
        make.centerX.mas_equalTo(self.view.mas_centerX);
        
    }];
    _imgHeader.layer.cornerRadius = 20;
    _imgHeader.clipsToBounds = YES;
    [_imgHeader release];
    
}

#pragma mark - ------------ 创建按钮回来 ---------------
- (void)creatBack
{
    
    self.buttonOk = [BaseButton buttonWithType:UIButtonTypeSystem];
    [_buttonOk setImage:[[UIImage imageNamed:@"quxiao"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]forState:UIControlStateNormal];
    [self.imgBack addSubview:_buttonOk];
    [_buttonOk addTarget:self action:@selector(backModal) forControlEvents:UIControlEventTouchUpInside];
    
    _buttonOk.translatesAutoresizingMaskIntoConstraints = NO;
    [_buttonOk mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.imgBack).offset(20);
        make.left.mas_equalTo(self.imgBack).offset(10);
        make.width.height.mas_equalTo(30);
    }];
    
}

- (void)backModal
{
    
    [self dismissViewControllerAnimated:YES completion:^{
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
